<?php include('includes/start.php'); ?>

<?php
echo "<h2>New Additions</h2>";
$con = mysql_connect($dbserver, $dbuser, $dbpass);
if (!$con)
{
	echo "<p>Connection to server failed</p>";
}
else
{
	mysql_select_db($db, $con);

	$q = $book_keyword_search;
		
		$q = $book_keyword_search;
		$sq = $book_keyword_search_params; 
		$q = split_query_replace($q, $sq,'');
		$q = add_order($q, 'media_id', 'DESC');
		$q = add_limit($q, 0, 3);
		
		$result = mysql_query($q);
		mysql_close($con);
	if (mysql_num_rows($result) == 0)
	{
		echo "<div id='no_books'>";
		echo "<p>No books found</p>";
		echo "</div>";
	}
	else
	{
		echo "<table id='DB_search_results'><tr>";
		while($row = mysql_fetch_array($result))
		{
			echo "<td>";
			$file = $row['cover_image'];
			if (!file_exists($file))
			{
				$file = $book_not_found;
			}
			echo "<div id='book'>\n";
			echo "<a href='book.php?id=" . $row['media_id'] . "'>";
			echo "<h3>" . $row['title'] . "</h3><br />";
			echo "<div id='bookimgContainer'><img id='bookimg' src=\"" . $file . "\" /></div>";
			echo "<p id='book_authors'>By: " . $row['authors'] . "</p>";
			echo "<br />";
			echo "</a>";
			echo "</div> <!-- end #book -->";
			echo "</td>";
		}
		echo "</tr></table> <!-- end #books -->";
	}

	
}
?>

<?php include('includes/stop.php'); ?>
